package File流作业;

import java.io.File;
import java.io.FilenameFilter;
import java.util.Scanner;

//1. 搜索某文件夹中所有的.jpg文件
public class Test01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入文件路径");
        String str =scanner.next();
        File f = new File(str);
        File [] files = f.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith(".jpg");
            }
        });
        for (int i = 0; i < files.length; i++) {
            if(!(files[i]==null)){
                System.out.println(files[i]);
            }else {
                System.out.println("该目录下没有jpg文件");
            }
        }
    }
}
